package demo02;

import java.util.ArrayList;
import java.util.Random;

public class QunZhu extends User {
    public QunZhu() {

    }

    public QunZhu(String UserName, double leftMoney) {
        super(UserName, leftMoney);
    }

    public ArrayList<Double> sendRedPacket(double Money, int Count) {
        double leftMoney = getLeftMoney();
        if (Money > leftMoney) {
            System.out.println("余额不足，当前余额为：" + leftMoney);
            return new ArrayList<Double>();
        }
        leftMoney = leftMoney - Money;
        setLeftMoney(leftMoney);
        ArrayList<Double> arrayList = new ArrayList<Double>();
        for (int i = 0; i < Count-1; i++) {
            double devideMoney = Money;
            devideMoney = new Random().nextDouble() * devideMoney;
            arrayList.add(devideMoney);
            Money=Money-devideMoney;
        }
        arrayList.add(Money);
        return arrayList;
    }
}
